package com.dfiov.cloud.msmtools.mapper.entity.msinfofeedback;

import com.pateo.qingcloud.framework.common.statusCode.CommonStatusCode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter
@ToString
@ApiModel(value = "统一返回泛型结果集")
public class ResultData<T> {
	
	@ApiModelProperty("返回码")
	private String statusCode;
	
	@ApiModelProperty("返回码描述")
	private String statusMessage;
	
	@ApiModelProperty("返回数据")
	private T data;

	public ResultData() {
		this(null);
	}

	public ResultData(T t) {
		this.statusCode = CommonStatusCode.SUCCESS0.getCode();
		this.statusMessage = CommonStatusCode.SUCCESS0.getDetail();
		this.data = t;
	}

	public ResultData(String statusCode, String statusMessage) {
		this.statusCode = statusCode;
		this.statusMessage = statusMessage;
	}

	public ResultData(String statusCode, String statusMessage, T t) {
		this.statusCode = statusCode;
		this.statusMessage = statusMessage;
		this.data = t;
	}

	public static <T> ResultData<T> success() {
		return new ResultData<>();
	}

	public static <T> ResultData<T> success(T t) {
		return new ResultData<>(t);
	}

	public static <T> ResultData<T> failed(String statusCode, String statusMessage) {
		return new ResultData<>(statusCode, statusMessage);
	}
}
